<template>
  <el-container class="layout-container">
    <!-- 侧边栏 -->
    <el-aside width="220px" class="sidebar">
      <div class="logo">
        <el-icon class="logo-icon"><UserFilled /></el-icon>
        <h2>式神管理系统</h2>
      </div>
      <el-menu
        :default-active="$route.path"
        router
        class="sidebar-menu"
        background-color="#304156"
        text-color="#bfcbd9"
        active-text-color="#409EFF"
        :collapse-transition="true"
        unique-opened
      >
        <el-menu-item index="/shishen">
          <el-icon><User /></el-icon>
          <span>式神管理</span>
        </el-menu-item>
        <el-menu-item index="/test">
          <el-icon><Connection /></el-icon>
          <span>连接测试</span>
        </el-menu-item>
      </el-menu>
    </el-aside>

    <!-- 主内容区 -->
    <el-container>
      <!-- 头部 -->
      <el-header class="header">
        <div class="header-left">
          <el-breadcrumb separator="/" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }" class="breadcrumb-item">
              <el-icon size="14"><HomeFilled /></el-icon>
              <span>首页</span>
            </el-breadcrumb-item>
            <el-breadcrumb-item class="breadcrumb-item">
              {{ $route.meta.title || $route.name }}
            </el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <div class="header-right">
          <el-dropdown class="user-dropdown">
            <span class="user-info">
              <el-avatar class="user-avatar" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
              <span class="user-name">管理员</span>
              <el-icon class="user-arrow"><CaretBottom /></el-icon>
            </span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>个人中心</el-dropdown-item>
                <el-dropdown-item>退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </el-header>

      <!-- 内容区域 -->
      <el-main class="main-content">
        <div class="content-wrapper fade-in">
          <router-view />
        </div>
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import { User, UserFilled, Connection, HomeFilled, CaretBottom } from '@element-plus/icons-vue'
</script>

<style scoped>
.layout-container {
  height: 100vh;
}

.sidebar {
  background-color: #304156;
  height: 100vh;
  transition: all 0.3s ease;
  box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
}

.logo {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background-color: #2b2f3a;
  border-bottom: 1px solid #283443;
  padding: 0 20px;
}

.logo-icon {
  font-size: 24px;
  margin-right: 8px;
  color: #409eff;
}

.logo h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.sidebar-menu {
  border-right: none;
  padding: 10px 0;
}

.sidebar-menu .el-menu-item {
  height: 50px;
  line-height: 50px;
  font-size: 14px;
  transition: all 0.3s ease;
}

.sidebar-menu .el-menu-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-menu .el-menu-item.is-active {
  background-color: #409eff;
  color: #fff;
}

.header {
  background-color: #fff;
  border-bottom: 1px solid #e6e6e6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  height: 60px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  z-index: 100;
}

.breadcrumb {
  font-size: 14px;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
}

.breadcrumb-item .el-icon {
  margin-right: 4px;
}

.user-info {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.user-info:hover {
  background-color: #f5f7fa;
}

.user-avatar {
  width: 32px;
  height: 32px;
  margin-right: 8px;
}

.user-name {
  font-size: 14px;
  color: var(--text-regular);
}

.user-arrow {
  font-size: 12px;
  margin-left: 4px;
  color: var(--text-secondary);
}

.main-content {
  background-color: var(--bg-color);
  padding: 24px;
  overflow-y: auto;
}

.content-wrapper {
  background-color: var(--card-bg-color);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--box-shadow-light);
  min-height: calc(100vh - 168px);
}

/* 响应式调整 */
@media screen and (max-width: 768px) {
  .sidebar {
    width: 200px !important;
  }
  
  .header {
    padding: 0 15px;
  }
  
  .main-content {
    padding: 16px;
  }
  
  .content-wrapper {
    padding: 16px;
  }
}
</style>